package com.haoshuang.zhouzhoubang.ui.vm

import androidx.lifecycle.rxLifeScope
import com.haoshuang.zhouzhoubang.base.request
import com.mufeng.libs.base.BaseViewModel
import com.mufeng.libs.state.StateData
import com.mufeng.libs.state.StatefulMutableLiveData

class BindAlipayViewModel : BaseViewModel() {
    val getData = StatefulMutableLiveData<Any>()
        fun getData(vararg params: Pair<String, Any?>) {
            rxLifeScope.launch {
                request<Any>("/api/wallet/edit_alipay", *params,
                    onStart = {
                        getData.value = StateData.Loading
                    },
                    onError = { code, msg ->
                        getData.value = StateData.Error(code, msg)
                    }, onSuccess = {
                        getData.value = StateData.Success(it)
                    })
            }
        }
}